using System;
using System.Collections.Generic;

namespace SqlsugarService.Application.DTOs.LMZWorkSchedule
{
    /// <summary>
    /// LMZ质检系统列表显示DTO
    /// </summary>
    public class LMZWorkScheduleListDto
    {
        /// <summary>
        /// 质检记录ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 序号（来自工单任务）
        /// </summary>
        public int SequenceNumber { get; set; }

        /// <summary>
        /// 检验编号（任务编号）
        /// </summary>
        public string TaskNumber { get; set; } = string.Empty;

        /// <summary>
        /// 检验单号
        /// </summary>
        public string InspectionCode { get; set; } = string.Empty;

        /// <summary>
        /// 检验单名称
        /// </summary>
        public string InspectionName { get; set; } = string.Empty;

        /// <summary>
        /// 检验类型 (如：首检, 巡检, 末检)
        /// </summary>
        public string InspectionType { get; set; } = string.Empty;

        /// <summary>
        /// 状态 (如: 未质检, 已质检)
        /// </summary>
        public string Status { get; set; } = string.Empty;

        /// <summary>
        /// 产品Id
        /// </summary>
        public Guid ProductId { get; set; }

        /// <summary>
        /// 工序Id
        /// </summary>
        public Guid ProcessStepId { get; set; }

        /// <summary>
        /// 工序名称（来自工单任务）
        /// </summary>
        public string ProcessName { get; set; } = string.Empty;

        /// <summary>
        /// 站点Id
        /// </summary>
        public Guid StationId { get; set; }

        /// <summary>
        /// 班组Id
        /// </summary>
        public Guid TeamId { get; set; }

        /// <summary>
        /// 报工人员Id
        /// </summary>
        public Guid ReporterId { get; set; }

        /// <summary>
        /// 检验人员Id
        /// </summary>
        public Guid InspectorId { get; set; }

        /// <summary>
        /// 检验人员姓名
        /// </summary>
        public string InspectorName { get; set; } = string.Empty;

        /// <summary>
        /// 报工数量
        /// </summary>
        public int ReportedQuantity { get; set; }

        /// <summary>
        /// 报工时间
        /// </summary>
        public DateTime ReportTime { get; set; }

        /// <summary>
        /// 检验时间
        /// </summary>
        public DateTime? InspectionTime { get; set; }

        /// <summary>
        /// 检验部门
        /// </summary>
        public string InspectionDepartment { get; set; } = string.Empty;

        /// <summary>
        /// 检测数量
        /// </summary>
        public int? TestedQuantity { get; set; }

        /// <summary>
        /// 合格数量
        /// </summary>
        public int? QualifiedQuantity { get; set; }

        /// <summary>
        /// 不合格数量
        /// </summary>
        public int? UnqualifiedQuantity { get; set; }

        /// <summary>
        /// 检测结果 (如: 合格, 不合格)
        /// </summary>
        public string OverallResult { get; set; } = string.Empty;

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; } = string.Empty;

        /// <summary>
        /// 计划开始时间（来自工单任务）
        /// </summary>
        public DateTime PlanStartTime { get; set; }

        // ProductionOrder 相关字段
        /// <summary>
        /// 工单编号
        /// </summary>
        public string OrderNumber { get; set; } = string.Empty;

        /// <summary>
        /// 工单名称
        /// </summary>
        public string OrderName { get; set; } = string.Empty;

        /// <summary>
        /// 生产计划Id
        /// </summary>
        public Guid ProductionPlanId { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string Specification { get; set; } = string.Empty;

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; } = string.Empty;

        /// <summary>
        /// 工单计划生产数量
        /// </summary>
        public decimal OrderPlanQuantity { get; set; }

        /// <summary>
        /// 工单实际生产数量
        /// </summary>
        public decimal OrderActualQuantity { get; set; }

        /// <summary>
        /// 工单计划开始时间
        /// </summary>
        public DateTime OrderPlanStartTime { get; set; }

        /// <summary>
        /// 工单计划完成时间
        /// </summary>
        public DateTime OrderPlanEndTime { get; set; }

        /// <summary>
        /// 工单实际开始时间
        /// </summary>
        public DateTime? OrderActualStartTime { get; set; }

        /// <summary>
        /// 工单实际完成时间
        /// </summary>
        public DateTime? OrderActualEndTime { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>
        public string OrderStatus { get; set; } = string.Empty;
    }

    /// <summary>
    /// LMZ质检系统详细信息DTO
    /// </summary>
    public class LMZWorkScheduleDetailDto
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int SequenceNumber { get; set; }

        /// <summary>
        /// 检验编号（任务编号）
        /// </summary>
        public string TaskNumber { get; set; } = string.Empty;

        /// <summary>
        /// 检验号码（检验单号）
        /// </summary>
        public string InspectionCode { get; set; } = string.Empty;

        /// <summary>
        /// 工单名称
        /// </summary>
        public string OrderName { get; set; } = string.Empty;

        /// <summary>
        /// 任务名称
        /// </summary>
        public string TaskName { get; set; } = string.Empty;

        /// <summary>
        /// 站点名称
        /// </summary>
        public string StationName { get; set; } = string.Empty;

        /// <summary>
        /// 工序名称
        /// </summary>
        public string ProcessName { get; set; } = string.Empty;

        /// <summary>
        /// 产品名称
        /// </summary>
        public string ProductName { get; set; } = string.Empty;

        /// <summary>
        /// 产品编号
        /// </summary>
        public string ProductNumber { get; set; } = string.Empty;

        /// <summary>
        /// 班组名称
        /// </summary>
        public string TeamName { get; set; } = string.Empty;

        /// <summary>
        /// 任务负责人
        /// </summary>
        public string ResponsiblePerson { get; set; } = string.Empty;

        /// <summary>
        /// 员工人员（检验人）
        /// </summary>
        public string InspectorName { get; set; } = string.Empty;

        /// <summary>
        /// 质检（计划数量）
        /// </summary>
        public decimal PlanQuantity { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string Status { get; set; } = string.Empty;

        // ProductionOrder 相关字段
        /// <summary>
        /// 工单编号
        /// </summary>
        public string OrderNumber { get; set; } = string.Empty;

        /// <summary>
        /// 生产计划Id
        /// </summary>
        public Guid ProductionPlanId { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string Specification { get; set; } = string.Empty;

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; } = string.Empty;

        /// <summary>
        /// 工单计划生产数量
        /// </summary>
        public decimal OrderPlanQuantity { get; set; }

        /// <summary>
        /// 工单实际生产数量
        /// </summary>
        public decimal OrderActualQuantity { get; set; }

        /// <summary>
        /// 工单计划开始时间
        /// </summary>
        public DateTime OrderPlanStartTime { get; set; }

        /// <summary>
        /// 工单计划完成时间
        /// </summary>
        public DateTime OrderPlanEndTime { get; set; }

        /// <summary>
        /// 工单实际开始时间
        /// </summary>
        public DateTime? OrderActualStartTime { get; set; }

        /// <summary>
        /// 工单实际完成时间
        /// </summary>
        public DateTime? OrderActualEndTime { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>
        public string OrderStatus { get; set; } = string.Empty;

        // QualityInspectionPlanWorkReportEntity 相关字段
        /// <summary>
        /// 质检计划工单报告关联表ID
        /// </summary>
        public Guid? QualityInspectionPlanWorkReportId { get; set; }

        /// <summary>
        /// 质检计划ID
        /// </summary>
        public Guid? QualityInspectionPlanId { get; set; }

        /// <summary>
        /// 工单报告检验ID
        /// </summary>
        public Guid? WorkReportInspectionId { get; set; }

        /// <summary>
        /// 是否为当前版本
        /// </summary>
        public bool? IsCurrentVersion { get; set; }

        /// <summary>
        /// 生效时间
        /// </summary>
        public DateTime? EffectiveTime { get; set; }

        /// <summary>
        /// 失效时间
        /// </summary>
        public DateTime? ExpiryTime { get; set; }

        /// <summary>
        /// 质检备注
        /// </summary>
        public string QualityInspectionRemark { get; set; } = string.Empty;
    }

    /// <summary>
    /// LMZ质检系统查询参数DTO
    /// </summary>
    public class LMZWorkScheduleQueryDto
    {
        /// <summary>
        /// 工单名称
        /// </summary>
        public string? OrderName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 20;
    }
}